package oc.tm.sg.core.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUitls {
	
	/**
	 * 时间戳转换成日期格式字符串
	 * 
	 * @param seconds 精确到秒的字符串
	 * @param formatStr
	 * @return
	 */
	public static String timestamp2Date(long timestamp, String format) {
		String timestampStr=String.valueOf(timestamp);
		if (timestampStr.length()==10) {
			timestampStr=timestampStr + "000";
		}
		if (format == null || format.isEmpty()){
			format = "yyyy-MM-dd HH:mm:ss";
		}
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		return sdf.format(new Date(Long.valueOf(timestampStr)));
	}
}
